package com.lmh.graphdisease.service.impl;

import com.lmh.graphdisease.entity.UserEntity;
import com.lmh.graphdisease.repository.UserRepository;
import com.lmh.graphdisease.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * @author lmh
 * @desc
 * @date 2023/4/12
 */
@Service
public class UserServiceImpl implements UserService {


    @Autowired
    UserRepository userRepository;

    @Override
    public UserEntity findUserEntityByUsername(String name) {
        return userRepository.findUserEntityByUsername(name);
    }


    @Override
    public boolean registerUser(UserEntity userEntity) {
        UserEntity user = userRepository.findUserEntityByUsername(userEntity.getUsername());
        if(user != null){
            return false;
        }else {
            userRepository.addNormalUser(userEntity.getName(),userEntity.getUsername(),userEntity.getPassword());
            return true;
        }
    }
}
